/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Services;

import java.awt.List;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import common.Yemek;

/**
 *
 * @author akay
 */
public class DBYemekListesi {

    private DBcon dbcon;
    private static String sorgu = "select * from yemeklistesi";

    public DBYemekListesi() {
    }

    public ArrayList<Yemek> getYemekListesi() {
        ArrayList<Yemek> yemeks = new ArrayList<Yemek>();
        dbcon = new DBcon();
        Connection connection = dbcon.getconnect();
        Statement statement;
        try {
            statement = connection.createStatement();
            ResultSet rs = statement.executeQuery(sorgu);
            while (rs.next()) {
		yemeks.add(new Yemek(rs.getInt(1),rs.getString(2),rs.getDouble(3)));	
            }
        } catch (SQLException ex) {
            Logger.getLogger(DBYemekListesi.class.getName()).log(Level.SEVERE, null, ex);
        }

        dbcon.closeConnect(connection);
        return yemeks;
    }
}
